using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace PSE.Hosting.Management.Console
{
    public class Messages
    {
        #region Messages

        internal static string WriteHeader()
        {
            StringBuilder header = new StringBuilder();

            header.AppendLine("*************************************************************");
            header.Append("BM&FBOVESPA WCF Services Manager Tool, Version ");
            header.AppendLine(Assembly.GetExecutingAssembly().GetName().Version.ToString());
            header.AppendLine("*************************************************************");
            header.AppendLine();

            return header.ToString();
        }

        internal static string WriteFooter()
        {
            StringBuilder footer = new StringBuilder();
            footer.AppendLine();
            footer.AppendLine("If you would like more help, type \"HosterConsole.exe /help\"");

            return footer.ToString();
        }

        #endregion

        #region ErrorMessages

        internal static void WriteError(string error)
        {
            StringBuilder errorMessage = new StringBuilder();
            errorMessage.Append(WriteHeader());
            errorMessage.Append("Error: ");
            errorMessage.AppendLine(error);
            errorMessage.AppendLine(WriteFooter());
            System.Console.Write(errorMessage.ToString());
        }

        internal static void WriteFailMessage(string message)
        {
            StringBuilder failMessage = new StringBuilder();
            failMessage.Append(WriteHeader());
            failMessage.Append("Failed: ");
            failMessage.AppendLine(message);
            failMessage.AppendLine(WriteFooter());
        }

        internal static void InvalidArgumentError(string error)
        {
            WriteError(error);
        }

        /// <summary>
        /// Writes to console an error that an unrecognized command was issued by the user.
        /// </summary>
        /// <param name="command">the unrecognized command</param>
        internal static void CommandSyntaxError(string command)
        {
            string error = "Unrecognized command '" + command + "' specified.";
            WriteError(error);
        }

        /// <summary>
        /// Writes to console an error that a package name must be specified.
        /// </summary>
        internal static void NoPackageSpecifiedError()
        {
            string error = "A package name must be specified.";
            WriteError(error);
        }

        internal static void NoFileSpecifiedError()
        {
            string error = "A file name must be specified.";
            WriteError(error);
        }

        internal static void FileDoesNotExistsError()
        {
            string error = "The specified file does not exists. Please check the syntax and try again.";
            WriteError(error);
        }

        internal static void PackageAlreadyExistsError()
        {
            string error = "Package already exists.";
            WriteError(error);
        }

        internal static void NoArgsSyntaxError()
        {
            string error = "No command specified.";
            WriteError(error);
        }

        internal static void CreatePackageSyntaxError()
        {
            string error = "Invalid create package command.";
            WriteError(error);
        }

        internal static void StartPackageSyntaxError()
        {
            string error = "Invalid start package command.";
            WriteError(error);
        }

        internal static void StopPackageSyntaxError()
        {
            string error = "Invalid stop package command.";
            WriteError(error);
        }

        internal static void InvalidHelpCommand()
        {
            string error = "Invalid help command.";
            WriteError(error);
        }

        internal static void RemovePackageSyntaxError()
        {
            string error = "Invalid remove package command.";
            WriteError(error);
        }

        internal static void InvalidOptionError(string option)
        {
            string error = "The option '" + option + "' specified is invalid.";
            WriteError(error);
        }

        #endregion
    }
}
